{*
 * Copyright (C) 2012-2013 ozok <ozok26@gmail.com>
 *
 * This file is part of TAudioConverter.
 *
 * TAudioConverter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * TAudioConverter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TAudioConverter.  If not, see <http://www.gnu.org/licenses/>.
 *
 *}

unit UnitInfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, sSkinProvider, sListBox, Vcl.Buttons, sBitBtn, Vcl.ComCtrls,
  JvExControls, JvXPCore, JvXPButtons, acPNG;

type
  TInfoForm = class(TForm)
    CloseBtn: TsBitBtn;
    SaveDialog1: TSaveDialog;
    SaveBtn: TsBitBtn;
    InfoList: TListView;
    sSkinProvider1: TsSkinProvider;
    procedure CloseBtnClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SaveBtnClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure InfoListAdvancedCustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
      var DefaultDraw: Boolean);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
    InfoTMP: TStringList;
  end;

var
  InfoForm: TInfoForm;

implementation

{$R *.dfm}

procedure TInfoForm.CloseBtnClick(Sender: TObject);
begin

  Self.Close;

end;

procedure TInfoForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin

  InfoList.Items.Clear;
  InfoTMP.Clear;

end;

procedure TInfoForm.FormCreate(Sender: TObject);
begin

  InfoTMP := TStringList.Create;

end;

procedure TInfoForm.FormDestroy(Sender: TObject);
begin

  FreeAndNil(InfoTMP);

end;

procedure TInfoForm.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  if Key = VK_ESCAPE then
  begin
    Close;
  end;

end;

procedure TInfoForm.InfoListAdvancedCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
  var DefaultDraw: Boolean);
begin

  if Item.SubItems[0] = '' then
  begin
    Sender.Canvas.Font.Style := [fsBold];
  end
  else
  begin
    Sender.Canvas.Font.Style := [];
  end;

end;

procedure TInfoForm.SaveBtnClick(Sender: TObject);
begin

  if InfoList.Items.Count > 0 then
  begin

    if SaveDialog1.Execute then
    begin
      InfoTMP.SaveToFile(SaveDialog1.FileName);
    end;

  end;

end;

end.
